Repository navigation
fix(web): theme CSS shorthands with var() can no longer load remote files - #39408
juliusmarminge wants to merge 2 commits into
Conversation
…iles Theme CSS must not fetch, but the client guard read each longhand's value, and a shorthand holding var() leaves its longhands reading "" until substitution. `background: var(--none, url(https://example.com/h))` passed the guard and the browser requested the URL. The guard now also judges pending longhands. While the block's cssText shows the shorthand, that text decides. Once a later declaration overrides one longhand the browser hides the text, so the theme's source decides: declarations that could fetch are split out, the browser parses each one alone, and only the longhands such a shorthand leaves pending are removed from blocks that hide them. A harmless overridden shorthand stays, whatever escapes or fetches the rest of the sheet holds. Co-authored-by: elias1218 <69803556+elias1218@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…theirs
The guard removed hidden pending longhands by name across the whole sheet,
so `.unused { background: var(--none, url(https://example.com/x)); }` took
the gradient from a harmless `background: var(...); background-color: red;`
in another rule.
A var() shorthand that can fetch is now cut from the theme's source before
the sheet is built, so removal is tied to that one declaration and nothing
is left for a later declaration to hide. Blocks that keep a pending
shorthand are no longer judged by what other rules hold.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Theme CSS must not load remote files, but a shorthand containing
var()slipped past the client guard: forbackground: var(--none, url(https://example.com/h))every longhand reads as empty until substitution, so the per-property check saw nothing and the browser requested the URL. Such shorthands are now removed, including when a later declaration in the same block overrides one of their longhands and the browser hides the shorthand's text.packages/shared/src/themeCss.ts:themeCssWithoutDeclarationssplits the theme source into declarations and drops the ones the caller refuses, asking only about text that could fetch.apps/web/src/themeCss.ts: before building the theme sheet,withoutFetchingShorthandslets the browser parse each such declaration alone and cuts it from the source when it is avar()shorthand that can fetch, so CSS escapes cannot dodge the check.stripDeclarationsalso removes the pending longhands of a block whose owncssTextstill shows a fetching shorthand.background: var(--theme-background-image) center / cover no-repeat;is kept, and so is avar()shorthand with an overridden longhand, whatever other rules in the theme hold.Supersedes #39346. The change is @elias1218's; their commits are kept.
Reproduction on main
Reproduced on main at 66b8a94:
[data-workspace-area="conversation"] { background: var(--screen-missing, url(https://example.com/theme-shorthand-probe-override2)); background-color: red; }: Chromium sent GET https://example.com/theme-shorthand-probe-override2. The filtered adopted sheet still held the rule with empty values for every background longhand (background-image: ; ... background-color: red;). Computed background-image was url("https://example.com/theme-shorthand-probe-override2") and background-color was rgb(255, 0, 0). Intact case, the same rule without background-color: the adopted sheet kept the shorthand as written, Chromium sent GET https://example.com/theme-shorthand-probe-intact, and the computed background-image was that URL. On main, theme CSS applied by the web client loads remote resources through var() shorthands in both of the forms the pull request names. Not checked here: the server-side escaped-function-name text check.Evidence
In Chromium, import and select each dark theme through Settings > Appearance, then open a seeded conversation. Test background: var(--screen-missing, url(...)) both with and without a later background-color: red. Browser routing records attempted remote requests and supplies the visible probe image; the labeled instrumentation reports requests and computed background-image.
Proven: scenarios:prove exited 0. Both forms request an image on base; neither requests one on head.
Scenario source · Before recording · After recording
Not shown:
Tests
vp test run --project browser src/themeCss.browser.test.ts(apps/web, two-rule case against the earlier commit d814c26): failed as expected,expected 'none' to contain 'linear-gradient'vp test run --project browser src/themeCss.browser.test.ts(apps/web, at 3b7520b): 1 passedvp test run src/themeCss.test.ts(packages/shared): 37 passedvp run check:changed: format, lint, knip, typecheck (36 packages), test (3 files) and react compiler all passNot in this change
themeCssLoadsRemoteFilesis unchanged; it stays early feedback that escapes can dodge, and the client check remains the guard.var()shorthand whose own value holds a CSS escape is still removed even when it cannot fetch, matching how the existing check refuses escapes in values.Who did the work
Run by the t3code factory in T3 Code.